import time

from selenium.webdriver.common.by import By

from Pages import BasePage

class adminVisaDetailPage(BasePage.Action):
    def __init__(self):
        #处理按钮
        self.process_xpath = (By.XPATH, "//button/span[contains(text(),'处理')]")

        #处理分配
        self.distributeOrder_xpath = (By.XPATH, "//div[not(contains(@style,'display: none;'))]/div[@aria-label='签证单处理']//label[text()='处理类型']/following-sibling::div/div/label/span[text()='分配处理']")
        #关闭订单
        self.closeOrder_xpath = (By.XPATH, "//div[not(contains(@style,'display: none;'))]/div[@aria-label='签证单处理']//label[text()='处理类型']/following-sibling::div/div/label/span[text()='关闭订单']")
        #转派处理
        self.redistributeOrder_xpath = (By.XPATH, "//div[not(contains(@style,'display: none;'))]/div[@aria-label='签证单处理']//label[text()='处理类型']/following-sibling::div/div/label/span[text()='转派处理']")
        #材料预审
        self.prequalification_xpath = (By.XPATH, "//div[not(contains(@style,'display: none;'))]/div[@aria-label='签证单处理']//label[text()='处理类型']/following-sibling::div/div/label/span[text()='材料预审']")

        #签证产品
        self.visaProduct_xpath = (By.XPATH, "//input[@placeholder='请选择签证产品']")
        #新增出行人
        self.addPassenger_xpath = (By.XPATH, "//button/span[text()='新增出行人']")
        #删除出行人
        self.deletePassenger_xpath = (By.XPATH, "//div/button/span[text()='删除']")
        #新增出行人模块
        self.employeeType_xpath = (By.XPATH, "//label[text()='员工类别']/following-sibling::div/div")

        self.lastName_xpath = (By.XPATH, "//label/span[text()='姓']/../following-sibling::div/div/input")
        self.firstName_xpath = (By.XPATH, "//label/span[text()='名']/../following-sibling::div/div/input")
        self.sex_xpath = (By.XPATH, "//label/span[text()='性别']/../following-sibling::div/div")
        self.sexMale_xpath = (By.XPATH, "//ul/li/span[text()='男']")
        self.sexFemale_xpath = (By.XPATH, "//ul/li/span[text()='女']")
        self.birthDate_xpath = (By.XPATH, "//label/span[text()='出生年月']/../following-sibling::div/div/input")


        #备注
        self.remark_xpath = (By.XPATH, "//label[text()='备注']/following-sibling::div/div/textarea")
        #确认按钮
        self.sureBtn_xpath = (By.XPATH, "//div[not(contains(@style,'display: none;'))]/div[@aria-label='签证单处理']/div[@class='el-dialog__footer']/span/button/span[text()='确 认']")
        #处理人下拉选择框
        self.operator_xpath = (By.XPATH, "//label[text()='分配处理人']/following-sibling::div/div/div/input[@placeholder='请选择']")
        #下拉选择处理人-丁微微
        self.selectedOperator_xpath = (By.XPATH, "//li[@class='el-select-dropdown__item selected']/following-sibling::li/span[text()='丁微微']")
        #关闭原因下拉选择框
        self.closeReason_xpath = (By.XPATH, "//label[@for='CloseReason']/following-sibling::div/div/div/input[@placeholder='请选择']")
        #关闭原因选择-其他
        self.otherReason_xpath = (By.XPATH, "//ul[@class='el-scrollbar__view el-select-dropdown__list']/li/span[text()='其他']")


    def clickProcess(self):
        self.smart_click(*self.process_xpath)
        time.sleep(1)

    #处理分配
    def distributeOrder(self):
        self.clickProcess()
        time.sleep(5)
        self.smart_click(*self.distributeOrder_xpath)
        time.sleep(1)
        self.smart_click(*self.operator_xpath)
        time.sleep(1)
        self.scroll_into_view(self.find_element(*self.selectedOperator_xpath))
        self.smart_click(*self.selectedOperator_xpath)
        time.sleep(1)
        self.find_element(*self.remark_xpath).send_keys("1111自动化测试备注2222remark3333")
        time.sleep(1)
        self.find_element(*self.sureBtn_xpath).click()
        time.sleep(1)
        self.refresh_window()

    #关闭订单
    def closeOrder(self):
        self.clickProcess()
        self.smart_click(*self.closeOrder_xpath)
        time.sleep(1)
        self.smart_click(*self.closeReason_xpath)
        time.sleep(1)
        self.scroll_into_view(self.find_element(*self.otherReason_xpath))
        self.smart_click(*self.otherReason_xpath)
        time.sleep(1)
        self.find_element(*self.remark_xpath).send_keys("自动化测试关闭订单备注111222333")
        time.sleep(1)
        self.find_element(*self.sureBtn_xpath).click()
        time.sleep(1)
        self.refresh_window()

    #转派处理
    def redistributeOrder(self):
        self.clickProcess()
        self.smart_click(*self.redistributeOrder_xpath)
        time.sleep(1)
        self.smart_click(*self.operator_xpath)
        time.sleep(1)
        self.scroll_into_view(self.find_element(*self.selectedOperator_xpath))
        self.smart_click(*self.selectedOperator_xpath)
        time.sleep(1)
        self.find_element(*self.remark_xpath).send_keys("1111自动化测试备注2222remark3333")
        time.sleep(1)
        self.find_element(*self.sureBtn_xpath).click()
        time.sleep(1)
        self.refresh_window()

    #材料预审
    def prequalifyMaterials(self):
        self.clickProcess()
        self.smart_click(*self.prequalification_xpath)
        time.sleep(1)
        pass

    def addPassenger(self):
        pass

    def deletePassenger(self):
        pass

    def modifyPassenger(self):
        pass